package site.psvm;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

//泛型-类型擦除
public class Demo1 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        List<String> list1 = new ArrayList<>();
        list1.add("a");
        list1.add("b");
        //编译器报错
        //list1.add(1);

        Method addMethod = list1.getClass().getDeclaredMethod("add", Object.class);
        addMethod.invoke(list1, 1);

        System.out.println(list1);
    }
}
